{extend name="public:head"}
{block name="main"}

<form class="layui-form" style="margin: 20px">
    <div class="demoTable">
        条件搜索：
        <div class="layui-inline">
            <select name="username">
                <option value="">用户</option>
                {volist name="username" id="vo"}
                <option value="{$vo.username}">{$vo.username}</option>
                {/volist}
            </select>
        </div>
        <div class="layui-input-inline">
            <input name="time" type="text" class="layui-input" id="date" placeholder="输入时间范围">
        </div>
        <div class="layui-inline">
            <button class="layui-btn" lay-filter="submit" lay-submit>搜索</button>
            <button class="layui-btn layui-btn-primary"  lay-filter="submit" lay-submit>重置</button>
        </div>

    </div>
</form>

<table class="layui-hide" id="all" lay-filter="all" lay-data="{id: 'sousuo'}"></table>

<!--<script type="text/html" id="barDemo">-->
    <!--<a class="layui-btn layui-btn-sm" lay-event="edit">编辑</a>-->
    <!--<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>-->
<!--</script>-->

<!--<script type="text/html" id="status">-->
    <!--<input type="checkbox" name="status"  lay-skin="switch" lay-text="开启|禁用" {{#  if(d.status == 1){ }} checked {{#  } }}>-->
<!--</script>-->

<script>
    layui.use(['table','layer','form','laydate'], function(){
        var table = layui.table;
        var laydate = layui.laydate;
        var form = layui.form;
        table.render({
            elem: '#all'
            ,url:'/admin/Log/getAllLogApi'
            ,toolbar: '#toolbarDemo'
            ,cols: [[
                {field:'id', title:'id'}
                ,{field:'username', title:'用户名'}
                ,{field:'ip', title:'用户名'}
                ,{field:'action', title:'操作行为'}
                ,{field:'add_time', title:'操作时间'}
            ]]
            ,page: true
        });
        // 表格重载 用于搜索
        form.on('submit(submit)', function(data){
            var field=data.field;
            if($(data.elem).html()=="重置"){
                $("input").val("");
                field="";
            }
            table.reload('all', {
                url: '/admin/Log/getLogByCondition',
                where: {field}
            });
            return false;
        });
        laydate.render({
            elem: '#date' //指定元素
            ,range: '.'
        });
    });
</script>


{/block}